#include "implementations/world/World.h"


namespace chakra
{
	void World::doStep()
	{
		for (Updaters::iterator it = m_updaters.begin(), itE = m_updaters.end(); it != itE; it++)
		{
			(*it)->update();
		}
	}

	void World::start()
	{

	}

	void World::stop()
	{

	}

	void World::addEntity(chakra::IChakraEntity* entity)
	{	
		_ASSERT(entity != NULL);
		EntityIDMap::iterator itr = m_existingEntityIDMap.find(entity->getTypeId());
		if(itr != m_existingEntityIDMap.end())
		{
			m_existingEntityIDMap.insert(IEntityPair(entity->getTypeId(), entity));
		}
		else
		{
			_ASSERT(false);
		}
	}

	void World::addUpdater( IUpdater* updater )
	{
		_ASSERT(updater != NULL);
		m_updaters.push_back(updater);
	}

	const vnav::RoadNetwork* World::getRoadNetwork()
	{
		throw new std::exception("not implemented");
	}

	World::~World()
	{
		for (Updaters::iterator it = m_updaters.begin(), itE = m_updaters.end(); it != itE; it++)
		{
			delete *it;
		}
		m_updaters.clear();
	}

	World::World()
	{

	}

}